//-----------------Sonic CD BULLET Gun Script-------------------//
//------------------Scripted by makasinaaaa-------------------//
// Yeah...

// Aliases
#alias Object.Value0	:	Object.Timer
#alias Object.Value1	:	Object.Timer1
#alias Object.Value2	:	Object.Timer2
#alias Object.Value3	:	Object.YVelocity
#alias Object.Value4	:	Object.XVelocity

// Collision Sides
#alias 0	:	CSIDE_FLOOR
#alias 1	:	CSIDE_LWALL
#alias 2	:	CSIDE_RWALL
// States
#alias 0	:	BULLET_FLY
#alias 1	:	BULLET_FALLEN

sub ObjectMain
	switch Object.PropertyValue
		case 0
			ObjectTileCollision(CSIDE_LWALL, -12, 0, 0)
			if CheckResult == true
				Object.State = BULLET_FALLEN
			end if
			if Object.State == BULLET_FLY
				Object.XVelocity = -0x25000
				Object.XPos += Object.XVelocity
			else
				Object.Timer++
			end if
			if Object.Timer == 12
				ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, Object.XPos, Object.YPos)
			end if
			break
		case 1
			ObjectTileCollision(CSIDE_RWALL, 12, 0, 0)
			if CheckResult == true
				Object.State = BULLET_FALLEN
			end if
			if Object.State == BULLET_FLY
				Object.XVelocity = 0x25000
				Object.XPos += Object.XVelocity
			else
				Object.Timer++
			end if
			if Object.Timer == 12
				ResetObjectEntity(Object.EntityNo, TypeName[Blank Object], 0, Object.XPos, Object.YPos)
			end if
			break
	end switch
end sub

sub ObjectPlayerInteraction
	switch Object.PropertyValue
		case 0
		PlayerObjectCollision(C_TOUCH, -8, -8, 8, 16)
		if CheckResult == true
			CallFunction(Player_Hit)
		end if
		break
		case 1
		case 2
		PlayerObjectCollision(C_TOUCH, -8, -8, 16, 8)
		if CheckResult == true
			CallFunction(Player_Hit)
		end if
		break
	end switch
end sub

sub ObjectDraw
	DrawSprite(0)
end sub

sub ObjectStartup
	LoadSpriteSheet("R2/Objects.gif")

	SpriteFrame(-3, -3, 6, 6, 67, 130)
end sub